﻿program DelphiProject2;

{$APPTYPE CONSOLE}

uses
  SysUtils;


type
  TPoint3D = record
    X,Y,Z : Double;
  end;
  PPoint3D = ^TPoint3D;

procedure InitPoint(var Point:TPoint3D;X,Y,Z:Double);
begin
  Point.X := X;
  Point.Y := Y;
  Point.Z := Z;
end;

function CountDistance(Point:TPoint3D): Double;
begin
  Result := Sqrt(Point.X*Point.X+Point.Y*Point.Y+Point.Z*Point.Z);
end;

var
  Arr1 : Array[0..99] of Integer;
  Arr2 : Array of Integer;
  I : Integer;
  MyPoint : TPoint3D;
  MyPPoint : PPoint3D;
  Result : Double;

begin
  Setlength(Arr2,Length(Arr1));
  //给arr1赋值
  for I := 100 downto 1 do
  begin
    Arr1[100-I] := I;
  end;
  //把arr2赋值给arr1
  for I := Low(Arr1) to High(Arr2) do
  begin
    Arr2[I] := Arr1[I];
    Write(Arr2[I],' ');
  end;
  Writeln('');

  //初始化结构
  InitPoint(MyPoint,1,2,3);
  Writeln(MyPoint.X,MyPoint.Y,MyPoint.Z);

  //初始化指针
  New(MyPPoint);
  InitPoint(MyPPoint^,9,8,7);
  Writeln(MyPPoint.X,MyPPoint.Y,MyPPoint.Z);

  //计算距离
  Result := CountDistance(MyPoint);
  Writeln(Result);

  Readln;
end.
